package com.atguigu.spring5.service.impl;

import com.atguigu.spring5.dao.IAccountDao;
import com.atguigu.spring5.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author : wenchao.long
 * @date : Created in 2020/10/30 10:22 周五
 * @description :
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class AccountServiceImpl implements IAccountService {

    @Autowired
    private IAccountDao accountDao;

    @Override
    public void accountMoney() {
        // lucy少100
        accountDao.reduceMoney();

        // 模拟异常
        //int i = 10 / 0;

        // mary多100
        accountDao.addMoney();
    }
}
